//
//  SeekBrandDetailCell.m
//  cityCar
//
//  Created by yao on 14-10-31.
//  Copyright (c) 2014年 lanou3g.com 蓝鸥科技. All rights reserved.
//

#import "SeekBrandDetailCell.h"
#import "UIImageView+WebCache.h"

@implementation SeekBrandDetailCell

- (void)dealloc
{
    [_photoImage release];
    [_nameLabel release];
    [_priceLabel release];
    [_car release];
    [super dealloc];
}

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        // Initialization code
        
        self.photoImage = [[UIImageView alloc] init];
        [self.contentView addSubview:self.photoImage];
        [_photoImage release];
        
        self.nameLabel = [[UILabel alloc] init];
        [self.contentView addSubview:self.nameLabel];
        [_nameLabel release];
        
        self.priceLabel = [[UILabel alloc] init];
        [self.contentView addSubview:self.priceLabel];
        [_priceLabel release];
        
    }
    return self;
}

- (void)layoutSubviews
{
    [super layoutSubviews];
    [self setupView];
}

- (void)setupView
{
    CGFloat x = self.contentView.frame.size.width;
    CGFloat y = self.contentView.frame.size.height;
    
    self.photoImage.frame = CGRectMake(20, 5, 60, y - 10);
    self.nameLabel.frame = CGRectMake(90, 5, x - 90, (y - 10) / 2);
    self.priceLabel.frame = CGRectMake(90, 5 + (y - 10) / 2, x - 90, (y - 10) / 2);
    
    self.priceLabel.font = [UIFont systemFontOfSize:14];
    self.priceLabel.textColor = [UIColor redColor];
    
}

- (void)setCar:(Car *)car
{
    if (car != _car) {
        [_car release];
        _car = [car retain];
    }
    [self.photoImage sd_setImageWithURL:[NSURL URLWithString:_car.logo]];
    self.nameLabel.text = _car.name;
    self.priceLabel.text = _car.priceRange;
}

- (void)awakeFromNib
{
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated
{
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
